import Axios from "@/router/ycyaxios/axiosinstance";
const state = {
  //所有问题清单
  alllist: [],
  listlength: "",
  ///问题监督管理
  management: [],
  managementlength: "",
  idshow: [],
  ///问题审核管理
  auditlist: [],
  auditlistlength: "",
  //问题评价管理
  evaluelist: [],
  evaluelistlength: "",
  //问题历史管理
  historylist: [],
  historylistlength: "",
  tplist: [],
};

const getters = {};

const mutations = {
  //获取所有问题清单数据数据//////////
  getlist(state: any, a: any) {
    // console.log(111111111)
    let page:any = a.page.value;
    // console.log(page);
    let num = 10;
    Axios({
      method: "post",
      url: "questionList/findList",
      params: {
        Name: "Description",
        currentPage: page,
        pageSize: 10,
      },
    }).then((resp) => {
      console.log(resp.data.data);
      state.alllist.length = 0;
      let data = resp.data.data;
      state.alllist.push(...data);
      let b = resp.data.data.length;
      state.listlength = resp.data.data.length;
      //处理数据开始
      for (let i = 0; i < b; i++) {
        //      console.log(state.alllist[i].submitTime   //        )
        let data = new Date(state.alllist[i].submitTime);
        // console.log(data)
        const year: any = data.getFullYear();
        const years: any = year.toString();
        const day: any = data.getDate();
        const days: any = day.toString();
        const month: any = data.getMonth();
        const months: any = month.toString();
        const daytime: any = years + "-" + months + "-" + days;

        state.alllist[i].submitTime = daytime;
        //       console.log( state.alllist[i].submitTime)
      }
      //处理数据结束
    });
  },
  //条件选择清单数据
  sellist(state: any, a: any) {
       console.log(a.page)
    Axios({
      method: "post",
      url: "questionList/selectList",

      params: {
        area: "",
        currentPage:1,
        endtime:"",
        overstatic:"",
        pageSize: 10,
        property: "",
        startime:"",
        type:"" ,
        unit: "",
      },
    }).then((resp) => {
      console.log(111)
      console.log(resp.data)
      state.alllist.length = 0;
      let data = resp.data.data;
      state.alllist.push(...data);
      let b = resp.data.data.length;
      state.listlength = resp.data.data.length;
      //处理数据开始
      for (let i = 0; i < b; i++) {
        //      console.log(state.alllist[i].submitTime   //        )
        let data = new Date(state.alllist[i].submitTime);
        // console.log(data)
        const year: any = data.getFullYear();
        const years: any = year.toString();
        const day: any = data.getDate();
        const days: any = day.toString();
        const month: any = data.getMonth();
        const months: any = month.toString();
        const daytime: any = years + "-" + months + "-" + days;

        state.alllist[i].submitTime = daytime;
        //       console.log( state.alllist[i].submitTime)
      }
    });
  },
  ///搜索条件数据
  tjsellist(state: any, a: any) {
       console.log(a.tj)
    Axios({
      method: "post",
      url: "/questionList/selectList2",
      params: {
        Name: "Description",
        currentPage: 1,
        pageSize: 10,
        name: a.tj,
      },
    }).then((resp) => {
      state.alllist.length = 0;
      let data = resp.data.data;
      state.alllist.push(...data);
      let b = resp.data.data.length;
      state.listlength = resp.data.data.length;
      //处理数据开始
      for (let i = 0; i < b; i++) {
        //      console.log(state.alllist[i].submitTime   //        )
        let data = new Date(state.alllist[i].submitTime);
        // console.log(data)
        const year: any = data.getFullYear();
        const years: any = year.toString();
        const day: any = data.getDate();
        const days: any = day.toString();
        const month: any = data.getMonth();
        const months: any = month.toString();
        const daytime: any = years + "-" + months + "-" + days;

        state.alllist[i].submitTime = daytime;
        //       console.log( state.alllist[i].submitTime)
      }
    });
  },
  ///清单数据管理结束//////////////////
  ////问题督办数据开始/////////////////
  getmanagement(state: any, a: any) {
    let page = a.page;
    // console.log(page);
    let num = 10;
    Axios({
      method: "post",
      url: "questionList/findSupervision",
      params: {
        Name: "Description",
        currentPage: 1,
        pageSize: 10,
      },
    }).then((resp) => {
      console.log(resp.data.data);
      state.management.length = 0;
      let data = resp.data.data;
      state.management.push(...data);
      let b = resp.data.data.length;
      state.managementlength = resp.data.data.length;
      //处理数据开始
      for (let i = 0; i < b; i++) {
        //      console.log(state.alllist[i].submitTime   //        )
        let data = new Date(state.management[i].submitTime);
        // console.log(data)
        const year: any = data.getFullYear();
        const years: any = year.toString();
        const day: any = data.getDate();
        const days: any = day.toString();
        const month: any = data.getMonth();
        const months: any = month.toString();
        const daytime: any = years + "-" + months + "-" + days;

        state.management[i].submitTime = daytime;
        //       console.log( state.management[i])
      }
      //处理数据结束
      ///处理按钮
      for (let i = 0; i < b; i++) {
        let a: any = resp.data.data[i].type;
        // console.log(resp.data.data[i].type)
        //       console.log(a)
        if (a == "项目建设") {
          state.idshow.push(i);
          console.log(i)
        }
      }
    });
  },
  //条件查询数据开始
  selmanagement(state: any, a: any) {
    Axios({
      method: "post",
      url: "questionList/selectSupervision1",
      params: {
        area: "",
        currentPage: 1,
        date: null,
        day: null,
        hours: null,
        minutes: null,
        month: null,
        nanos: null,
        pageSize: 10,
        property: "",
        seconds: null,
        submitTime: null,
        time: null,
        timezoneOffset: null,
        type: "",
        unit: "",
        year: null,
      },
    }).then((resp) => {
      console.log(resp.data.data);
      state.management.length = 0;
      let data = resp.data.data;
      state.management.push(...data);
      let b = resp.data.data.length;
      state.managementlength = resp.data.data.length;
      //处理数据开始
      for (let i = 0; i < b; i++) {
        //      console.log(state.alllist[i].submitTime   //        )
        let data = new Date(state.management[i].submitTime);
        // console.log(data)
        const year: any = data.getFullYear();
        const years: any = year.toString();
        const day: any = data.getDate();
        const days: any = day.toString();
        const month: any = data.getMonth();
        const months: any = month.toString();
        const daytime: any = years + "-" + months + "-" + days;

        state.management[i].submitTime = daytime;
        //       console.log( state.management[i])
      }
    });
  },
  //条件查询结束
  //搜索条件查询开始
  tjselmannagement(state: any, a: any) {
    Axios({
      method: "post",
      url: "questionList/selectSupervision2",
      params: {
        Name: "Description",
        currentPage: a.page,
        pageSize: 10,
        condition: a.sel,
      },
    }).then((resp) => {
      console.log(resp.data.data);
      state.management.length = 0;
      let data = resp.data.data;
      state.management.push(...data);
      let b = resp.data.data.length;
      state.managementlength = resp.data.data.length;
      //处理数据开始
      for (let i = 0; i < b; i++) {
        //      console.log(state.alllist[i].submitTime   //        )
        let data = new Date(state.management[i].submitTime);
        // console.log(data)
        const year: any = data.getFullYear();
        const years: any = year.toString();
        const day: any = data.getDate();
        const days: any = day.toString();
        const month: any = data.getMonth();
        const months: any = month.toString();
        const daytime: any = years + "-" + months + "-" + days;

        state.management[i].submitTime = daytime;
        //       console.log( state.management[i])
      }
    });
  },
  //搜索条件查询结束
  //督办修改状态
  changmanagement(state: any, a: any) {
    //  console.log(a.data);
    //  console.log(a.id);
    state.management[a.id].submitTime = a.data;
  },
  /////问题督办数据结束//////////////
  ////问题审核管理开始///////////////
  getaudit(state: any, a: any) {
    let page = a.page;
    // console.log(page);
    let num = 10;
    Axios({
      method: "post",
      url: "questionList/findList",
      params: {
        Name: "Description",
        currentPage: page,
        pageSize: 10,
      },
    }).then((resp) => {
      state.auditlist.length = 0;
      let data = resp.data.data;
      state.auditlist.push(...data);
      let b = resp.data.data.length;
      state.auditlistlength = resp.data.data.length;
      //处理数据开始
      for (let i = 0; i < b; i++) {
        //      console.log(state.alllist[i].submitTime   //        )
        let data = new Date(state.auditlist[i].submitTime);
        // console.log(data)
        const year: any = data.getFullYear();
        const years: any = year.toString();
        const day: any = data.getDate();
        const days: any = day.toString();
        const month: any = data.getMonth();
        const months: any = month.toString();
        const daytime: any = years + "-" + months + "-" + days;

        state.auditlist[i].submitTime = daytime;
        //       console.log( state.alllist[i].submitTime)
      }
      //处理数据结束
    });
  },
  //条件选择清单数据
  selaudit(state: any, a: any) {
    Axios({
      method: "post",
      url: "questionList/selectReview1",
      params: {
        area: "",
        currentPage: 1,
        date: null,
        day: null,
        hours: null,
        minutes: null,
        month: null,
        nanos: null,
        pageSize: 10,
        property: "",
        seconds: null,
        submitTime: null,
        time: null,
        timezoneOffset: null,
        type: "",
        unit: "",
        year: null,
      },
    }).then((resp) => {
      state.auditlist.length = 0;
      let data = resp.data.data;
      state.auditlist.push(...data);
      let b = resp.data.data.length;
      state.auditlistlength = resp.data.data.length;
      //处理数据开始
      for (let i = 0; i < b; i++) {
        //      console.log(state.alllist[i].submitTime   //        )
        let data = new Date(state.auditlist[i].submitTime);
        // console.log(data)
        const year: any = data.getFullYear();
        const years: any = year.toString();
        const day: any = data.getDate();
        const days: any = day.toString();
        const month: any = data.getMonth();
        const months: any = month.toString();
        const daytime: any = years + "-" + months + "-" + days;

        state.auditlist[i].submitTime = daytime;
        //       console.log( state.alllist[i].submitTime)
      }
      //处理数据结束
    });
  },
  //搜索条件查询开始
  tjselaudit(state: any, a: any) {
    Axios({
      method: "post",
      url: "questionList/selectReview2",
      params: {
        Name: "Description",
        currentPage: a.page,
        pageSize: 10,
        condition: a.sel,
      },
    }).then((resp) => {
      state.auditlist.length = 0;
      let data = resp.data.data;
      state.auditlist.push(...data);
      let b = resp.data.data.length;
      state.auditlistlength = resp.data.data.length;
      //处理数据开始
      for (let i = 0; i < b; i++) {
        //      console.log(state.alllist[i].submitTime   //        )
        let data = new Date(state.auditlist[i].submitTime);
        // console.log(data)
        const year: any = data.getFullYear();
        const years: any = year.toString();
        const day: any = data.getDate();
        const days: any = day.toString();
        const month: any = data.getMonth();
        const months: any = month.toString();
        const daytime: any = years + "-" + months + "-" + days;

        state.auditlist[i].submitTime = daytime;
        //       console.log( state.alllist[i].submitTime)
      }
    });
  },
  //搜索条件查询结束
  ////问题审核管理结束////////////////
  ///问题评价开始/////////////////////
  //获取总数据
  getevalu(state: any, a: any) {
    let page = a.page;
    // console.log(page);
    let num = 10;
    Axios({
      method: "post",
      url: "questionList/findEvaluation",
      params: {
        Name: "Description",
        currentPage: page,
        pageSize: 10,
      },
    }).then((resp) => {
      console.log(resp);
      state.evaluelist.length = 0;
      let data = resp.data.data;
      state.evaluelist.push(...data);
      let b = resp.data.data.length;
      state.evaluelistlength = resp.data.data.length;
      //处理数据开始
      for (let i = 0; i < b; i++) {
        //      console.log(state.alllist[i].submitTime   //        )
        let data = new Date(state.evaluelist[i].submitTime);
        // console.log(data)
        const year: any = data.getFullYear();
        const years: any = year.toString();
        const day: any = data.getDate();
        const days: any = day.toString();
        const month: any = data.getMonth();
        const months: any = month.toString();
        const daytime: any = years + "-" + months + "-" + days;

        state.evaluelist[i].submitTime = daytime;
        //       console.log( state.alllist[i].submitTime)
      }
      //处理数据结束
    });
  },
  //条件查询数据开始
  selevalua(state: any, a: any) {
    Axios({
      method: "post",
      url: "questionList/selectHistory",
      params: {
        area: "",
        currentPage: 1,
        date: null,
        day: null,
        hours: null,
        minutes: null,
        month: null,
        nanos: null,
        pageSize: 10,
        property: "",
        seconds: null,
        submitTime: null,
        time: null,
        timezoneOffset: null,
        type: "",
        unit: "",
        year: null,
      },
    }).then((resp) => {
      console.log(resp);
      state.evaluelist.length = 0;
      let data = resp.data.data;
      state.evaluelist.push(...data);
      let b = resp.data.data.length;
      state.evaluelistlength = resp.data.data.length;
      //处理数据开始
      for (let i = 0; i < b; i++) {
        //      console.log(state.alllist[i].submitTime   //        )
        let data = new Date(state.evaluelist[i].submitTime);
        // console.log(data)
        const year: any = data.getFullYear();
        const years: any = year.toString();
        const day: any = data.getDate();
        const days: any = day.toString();
        const month: any = data.getMonth();
        const months: any = month.toString();
        const daytime: any = years + "-" + months + "-" + days;

        state.evaluelist[i].submitTime = daytime;
        //       console.log( state.alllist[i].submitTime)
      }
      //处理数据结束
    });
  },
  //条件查询结束
  //搜索条件查询开始
  tjselevalua(state: any, a: any) {
    Axios({
      method: "post",
      url: "questionList/selectEvaluation2",
      params: {
        Name: "Description",
        currentPage: a.page,
        pageSize: 10,
        condition: a.sel,
      },
    }).then((resp) => {
      console.log(resp);
      state.evaluelist.length = 0;
      let data = resp.data.data;
      state.evaluelist.push(...data);
      let b = resp.data.data.length;
      state.evaluelistlength = resp.data.data.length;
      //处理数据开始
      for (let i = 0; i < b; i++) {
        //      console.log(state.alllist[i].submitTime   //        )
        let data = new Date(state.evaluelist[i].submitTime);
        // console.log(data)
        const year: any = data.getFullYear();
        const years: any = year.toString();
        const day: any = data.getDate();
        const days: any = day.toString();
        const month: any = data.getMonth();
        const months: any = month.toString();
        const daytime: any = years + "-" + months + "-" + days;

        state.evaluelist[i].submitTime = daytime;
        //       console.log( state.alllist[i].submitTime)
      }
      //处理数据结束
    });
  },
  //搜索条件查询结束
  ///问题评价结束/////////////////////
  ///历史问题开始/////////////////////
  gethistory(state: any, a: any) {
    let page = a.page;
    // console.log(page);
    let num = 10;
    Axios({
      method: "post",
      url: "questionList/findHistory",
      params: {
        Name: "Description",
        currentPage: page,
        pageSize: 10,
      },
    }).then((resp) => {
      console.log(resp);
      state.historylist.length = 0;
      let data = resp.data.data;
      state.historylist.push(...data);
      let b = resp.data.data.length;
      state.historylistlength = resp.data.data.length;
      //处理数据开始
      for (let i = 0; i < b; i++) {
        //      console.log(state.alllist[i].submitTime   //        )
        let data = new Date(state.historylist[i].submitTime);
        // console.log(data)
        const year: any = data.getFullYear();
        const years: any = year.toString();
        const day: any = data.getDate();
        const days: any = day.toString();
        const month: any = data.getMonth();
        const months: any = month.toString();
        const daytime: any = years + "-" + months + "-" + days;

        state.historylist[i].submitTime = daytime;
        //       console.log( state.alllist[i].submitTime)
      }
      //处理数据结束
    });
  },
  //条件查询数据开始
  selhistory(state: any, a: any) {
    Axios({
      method: "post",
      url: "questionList/selectHistory",
      params: {
        area: "",
        currentPage: 1,
        date: null,
        day: null,
        hours: null,
        minutes: null,
        month: null,
        nanos: null,
        pageSize: 10,
        property: "",
        seconds: null,
        submitTime: null,
        time: null,
        timezoneOffset: null,
        type: "",
        unit: "",
        year: null,
      },
    }).then((resp) => {
      console.log(resp);
      state.historylist.length = 0;
      let data = resp.data.data;
      state.historylist.push(...data);
      let b = resp.data.data.length;
      state.historylistlength = resp.data.data.length;
      //处理数据开始
      for (let i = 0; i < b; i++) {
        //      console.log(state.alllist[i].submitTime   //        )
        let data = new Date(state.historylist[i].submitTime);
        // console.log(data)
        const year: any = data.getFullYear();
        const years: any = year.toString();
        const day: any = data.getDate();
        const days: any = day.toString();
        const month: any = data.getMonth();
        const months: any = month.toString();
        const daytime: any = years + "-" + months + "-" + days;

        state.historylist[i].submitTime = daytime;
        //       console.log( state.alllist[i].submitTime)
      }
      //处理数据结束
    });
  },
  //条件查询结束
  //搜索条件查询开始
  tjselhistory(state: any, a: any) {
    Axios({
      method: "post",
      url: "questionList/selectHistory2",
      params: {
        Name: "Description",
        currentPage: a.page,
        pageSize: 10,
        condition: a.sel,
      },
    }).then((resp) => {
      console.log(resp);
      state.historylist.length = 0;
      let data = resp.data.data;
      state.historylist.push(...data);
      let b = resp.data.data.length;
      state.historylistlength = resp.data.data.length;
      //处理数据开始
      for (let i = 0; i < b; i++) {
        //      console.log(state.alllist[i].submitTime   //        )
        let data = new Date(state.historylist[i].submitTime);
        // console.log(data)
        const year: any = data.getFullYear();
        const years: any = year.toString();
        const day: any = data.getDate();
        const days: any = day.toString();
        const month: any = data.getMonth();
        const months: any = month.toString();
        const daytime: any = years + "-" + months + "-" + days;

        state.historylist[i].submitTime = daytime;
        //       console.log( state.alllist[i].submitTime)
      }
      //处理数据结束
    });
  },
  ///历史问题结束/////////////////////
  ///////获取饼状图数开始
  gettu(state: any) {
    Axios({
      method: "post",
      url: "login/spselect",
      params: {
        endtime: 1,
        starttime: 1,
      },
    }).then((resp) => {
      state.tplist.length = 0;
      // console.log(resp.data.data)
      let data = JSON.parse(resp.data.data);
      state.tplist.push(data);
      console.log(state.tplist);
    });
  },
};

const actions = {};

export default {
  state,
  mutations,
  actions,
  getters,
};
